<?php
class friendmanagedao extends daobase {
	public function getMyFriends($userId){
		$sql = "select a.friend_class_id,b.friendName as name,b.tel as tel,b.qq as qq,b.msn as msn,b.e_mail as email,b.address as address,b.otherInfo as otherInfo from friend a,informationbook b where a.user_id = '$userId' and a.friend_id = b.id";
		$friends = $this->fetchit($sql);
		return $friends;
	}
	public function getFriendClass($userid){
		$sql = "select distinct b.id as id,b.class_name as name from friend_class b where b.user_id = '$userid' order by id asc";
		//echo $sql;
		$friendClass = $this->fetchit($sql);
		return $friendClass;
	}
	public function addNewTongXunFriend($post){
		$userId = $_SESSION["userId"];
		$name = $post["friendName"];
		$tel = $post["tel"];
		$qq = $post["qq"];
		$msn = $post["msn"];
		$e_mail = $post["email"];
		$address = $post["address"];
		$otherInfo = $post["otherInfo"];
		$feilei = $post['managefenlei'];
		$sql = "insert into informationbook(user_id,friendName,kind_id,tel,qq,msn,e_mail,address,otherInfo) values('$userId','$name','$feilei','$tel','$qq','$msn','$e_mail','$address','$otherInfo')";
		$query = $this->queryit($sql);
		return $query;
	}
	public function getFriendById($id){
		$sql = "select * from informationbook where id = '$id'";
		$friend = $this->fetchit($sql);
		return $friend[0];
	}
	public function updateFriend($updateId,$post){
		$name =$post["friendName"];
		$tel = $post["tel"];
		$qq = $post["qq"];
		$msn = $post["msn"];
		$email = $post["email"];
		$address = $post["address"];
		$otherInfo = $post["otherInfo"];
		$managefenlei = $post["managefenlei"];
		$sql = "update informationbook set friendName='$name',kind_id='$managefenlei',tel='$tel',
		qq='$qq',msn='$msn',e_mail='$email',address='$address',otherInfo='$otherInfo' where id = $updateId";
		$updateit = $this->queryit($sql);
		return $updateit;
	}
}
?>